package p2d

import (
	"encoding/binary"
	"hy_808/protocol/jtt808"
)

// 平台通用应答 0X8001
type PlatformAnswer struct {
	jtt808.Jtt808
	AnswerRegSN uint16 //应答流水号 对应的终端注册消息的流水号
	AnswerForId int    //应答的消息ID
	Result      byte   //结果 0：成功/确认；1：失败；2：消息有误；3：不支持
}

func ParsePlatformAnswer(p jtt808.Jtt808) PlatformAnswer {
	pa := PlatformAnswer{}
	pa.Head = p.Head
	body := p.GetBody()
	pa.AnswerRegSN = binary.BigEndian.Uint16(body[0:2])
	pa.AnswerForId = jtt808.ToInt(body[2:4])
	pa.Result = body[4]
	return pa
}
